package com.crazy.base.starter.transaction.properties;

import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;

import java.util.Objects;

@Data
@ConfigurationProperties(prefix = "base.transaction.rdb")
public class TransactionProperties {

    private boolean enabled = true;

    private String requiredPrefix;

    private String readonlyPrefix;

    private int methodTimeOut = -1;

    private String pointcutExpression;

    public String[] parseRequiredPrefix() {
        return Objects.nonNull(this.requiredPrefix) ? this.requiredPrefix.split(",") : new String[0];
    }

    public String[] parseReadonlyPrefix() {
        return Objects.nonNull(this.readonlyPrefix) ? this.readonlyPrefix.split(",") : new String[0];
    }

}
